Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Review: Use structured output for tag enrichment
Change summary
Replaces free-form
provider.complete("tag-extraction", …)with a dedicatedprovider.extractTags()method that uses the xAI/Grok Responses APIjson_schemastructured output mode. The contract layer gains a Zod schema (tagExtractionResultSchema) and a mirrored JSON Schema (tagExtractionJsonSchema) to validate the LLM response at both the API constraint level and at parse time.Files touched: 3 —
contracts/src/index.ts(new schemas),ai/src/index.ts(new method),web/trigger/tasks.ts(call-site simplified).Validation confidence: High
JSON.parseprovides a runtime safety net even if the model drifts.max(8)on the Zod array matches the system prompt instruction ("up to 8")Remaining risks
zod-to-json-schema).maxItemsin the JSON Schema — The Zod side enforces.max(8), but the JSON Schema sent to the model doesn't include"maxItems": 8, so the model could return >8 tags that then fail Zod parsing at runtime.JSON.parseon missingoutput_text— Falls back to"{}"which parses to{}, then Zod would accept{ tags: undefined }… except.array()won't coerceundefined. This will throw aZodErrorrather than returning{ tags: [] }like the disabled-provider path does. A graceful fallback or explicit check might be safer.fetchcall has noAbortSignaltimeout. A hung upstream will block the Trigger task indefinitely.z.string()with no regex constraint for URL-safety, relying entirely on the model to obey the system prompt.None of these are blockers — the change is a clear improvement over the unstructured path. Items 2 and 3 are the most actionable quick fixes.